import request from '@/utils/request'

/**
 * 查询企业的部门列表
 * @returns Promise
 */
export const getDepartmentList = () => {
  return request({
    method: 'get',
    url: '/company/department'
  })
}

/**
 * 根据id删除部门
 * @param {*} id 部门id
 * @returns
 */
export const delDepartment = (id) => {
  return request({
    method: 'delete',
    url: '/company/department/' + id
  })
}

/**
 * 添加部门
 * @param {*} data 部门数据 code introduce manager name pid
 * @returns Promise
 */
export const addDepartment = (data) => {
  return request({
    method: 'post',
    url: '/company/department',
    data
  })
}

/**
 * 根据id获取部门详情
 * @param {*} id id
 * @returns Promise
 */
export const getDepartmentDetail = (id) => {
  return request({
    method: 'get',
    url: '/company/department/' + id
  })
}

/**
 * 根据id修改部门
 * @param {*} id id
 * @returns Promise
 */
export const updateDepartment = (data) => {
  return request({
    method: 'put',
    url: '/company/department/' + data.id,
    data
  })
}
